Skip to content

feat(notebooks): add --markdown to get, create, update, and edit - #750

Merged
platinummonkey merged 1 commit into
DataDog:mainfrom
andyjmorgan:feat/notebooks-markdown
Aug 24, 2026
Merged

feat(notebooks): add --markdown to get, create, update, and edit#750
platinummonkey merged 1 commit into
DataDog:mainfrom
andyjmorgan:feat/notebooks-markdown

Conversation

@andyjmorgan

@andyjmorgan andyjmorgan commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Work with a notebook as a Markdown document instead of a JSON cells array:

pup notebooks get 12345 --markdown                      # print as Markdown
pup notebooks create --markdown --file doc.md           # create; prints the new id
pup notebooks update 12345 --markdown --file doc.md     # replace the document
pup notebooks edit 12345 --markdown --file fragment.md  # append server-side

These hit /api/unstable/notebooks, not yet promoted to /api/v2, so the flags are marked experimental in --help.

Changes

  • create --markdown prints the new notebook id, not the document. The id only exists in the JSON:API representation — per ADR-006 it is resource identity and deliberately absent from Markdown frontmatter — so create negotiates JSON:API and leaves reading the document to get:

    ID=$(pup notebooks create --markdown --file doc.md)
    pup notebooks get "$ID" --markdown
  • edit --markdown appends via the content-fragment endpoint. The JSON path fetches, splices, and rewrites the whole notebook; this does not.

  • --jq is rejected with --markdown, keyed on the flag rather than cfg.jq so an inherited PUP_FILTER does not block extension subprocesses.

  • JSON files passed with --markdown are rejected before any request.

  • Errors distinguish reads from writes. A notebook with no Markdown projection gives an actionable message; on a write, and on any failure to decode a 2xx response, the error says the change may already have landed, since retrying would duplicate a create or re-append a fragment.

  • Raw-text print helper moved to util_ext::print_text_document; skills remote get had the same inline idiom.

Testing

  • All four commands, request bodies and media types, content-type and empty-body guards, JSON-file and BOM-prefixed-JSON rejection, and the error-translation paths for reads, writes, and post-success decode failures.
  • Against the live API: create returns an id that get resolves, edit appends without disturbing existing content, update replaces, and a cells-era notebook gives the translated error rather than a raw 5xx.

Known gaps

  • Rich-text notebooks only. Notebooks from the older cells API have no Markdown projection.
  • update --markdown is lossy. Replaces the whole document, drops anything Markdown cannot represent. No prompt, matching JSON update.
  • No conflict detection. document_revision is returned but not enforced on any write path.
  • No targeted edits. update replaces, edit appends; no way to change one section in place.
  • --output and agent mode do nothing under --markdown, matching skills remote get.

@andyjmorgan
andyjmorgan requested a review from a team as a code owner August 21, 2026 14:37
@andyjmorgan
andyjmorgan force-pushed the feat/notebooks-markdown branch from bd17bdb to 691559e Compare August 21, 2026 14:55
@andyjmorgan
andyjmorgan marked this pull request as draft August 21, 2026 15:45
@andyjmorgan
andyjmorgan force-pushed the feat/notebooks-markdown branch 4 times, most recently from 2604b3f to e160e85 Compare August 24, 2026 11:34
Work with a notebook as a Markdown document instead of a JSON cells
array. These call /api/unstable/notebooks, which the notebooks team has
not promoted to /api/v2 yet, so the flag is documented as experimental.

- get --markdown prints the document; create/update take a Markdown file
- edit --markdown appends server-side via the content-fragment endpoint,
  so the rest of the document is not rewritten
- Reject --jq alongside --markdown, and reject JSON files passed with
  --markdown before any request is made
- Translate the backend's 5xx for notebooks that have no Markdown
  projection into an actionable message

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@andyjmorgan
andyjmorgan force-pushed the feat/notebooks-markdown branch from e160e85 to 2dc0147 Compare August 24, 2026 13:02
@andyjmorgan
andyjmorgan marked this pull request as ready for review August 24, 2026 14:12
@platinummonkey
platinummonkey merged commit 483e4c9 into DataDog:main Aug 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants